import request from './request'
import mockReq from './requestCopy'

//三级联动接口
export const reqCategoryList=()=>request({url:'api/product/getBaseCategoryList'})

//请求mockjs的数据
export const mockBanner=()=>mockReq({url:'/banner'})

//搜索商品的接口(没有数据的话一定要传入一个空对象要不然会报错)
export const reqGetSearchInfo=(params)=>request({url:'api/list',method:'POST',data:params})

//获取商品详情
export const getItem=(params)=>request({url:`api/item/${params}`})

//加入购物车
export const addToCart=(skuID,skuNum)=>request({url:`api/cart/addToCart/${skuID}/${skuNum}`,method:'POST'})

//获取购物车列表
export const cartList=()=>request({url:'api/cart/cartList'})

//删除购物车商品
export const delCart=(skuId)=>request({url:`api/cart/deleteCart/${skuId}`,method:'DELETE'})

//切换选中状态
export const checkCart=(skuId,isChecked)=>request({url:`api/cart/checkCart/${skuId}/${isChecked}`})

//获取验证码
export const sendCode=(phone)=>request({url:`api/user/passport/sendCode/${phone}`})

//用户注册
export const register=(params)=>request({url:'api/user/passport/register',method:'POST',data:params})

//用户登录
export const login=(params)=>request({url:'api/user/passport/login',method:'POST',data:params})

//获取用户信息[带token]
export const getUserInfo=()=>request({url:'api/user/passport/auth/getUserInfo'})

//退出登录
export const logout=()=>request({url:'api/user/passport/logout'})

//获取用户地址信息
export const userAddressList=()=>request({url:'api/user/userAddress/auth/findUserAddressList'})

//获取订单交易页信息
export const trade=()=>request({url:'api/order/auth/trade'})

//提交订单
export const submitOrder=(tradeNo,data)=>request({url:`api/order/auth/submitOrder?tradeNo=${tradeNo}`,method:'POST',data:data})

//获取订单支付信息
export const createNative=(orderId)=>request({url:`api/payment/weixin/createNative/${orderId}`})

//获取订单的支付状态
export const queryPayStatus=(orderId)=>request({url:`api/payment/weixin/queryPayStatus/${orderId}`})

//获取我的订单列表
export const orderAuth=(page,limit)=>request({url:`api/order/auth/${page}/${limit}`})